package ird.demo.service.impl;

import ird.demo.domain.Transaction;
import ird.demo.repository.TransactionRepository;
import ird.demo.service.TranService;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Service;

@Service
public class TranServiceImple implements TranService{

	@Autowired
	private TransactionRepository transactionRepository;
	
	public List<Transaction> findAllTran(){
		return transactionRepository.findAllTran();
	}
	
	public Page<Transaction> findPageTran(PageRequest request){
		return transactionRepository.findAll(request);
	}

	public Transaction findTranById(String pk){
		return transactionRepository.findOne(pk);
	}

	public List<Transaction> findTranInMenuByUsrGrp(String usrGrp){
		return transactionRepository.findTranInMenuByUsrGrp(usrGrp);
	}
	
	public List<Transaction> findTranInByMenuId(String menuId){
		return transactionRepository.findTranInByMenuId(menuId);
	}
	
	public List<Transaction> findTranByTranGrp(String tranGrp){
		return transactionRepository.findTranByTranGrp(tranGrp);
	}
	
	public void saveTran(Transaction tran){
		transactionRepository.save(tran);
	}
	
	public void delTran(String tranId){
		transactionRepository.delete(tranId);
	}
	
}
